<!DOCTYPE html>
<html>
<head>
	<title>设置角色权限管理</title>
	<include file='public/head'>
	<style>
		.layui-legend-size{font-size:14px !important;}
		.layui-nopadding{padding:0 !important;}
		.layui-overflow{overflow:auto;}
		.layui-nomargin{margin: 0 !important;}
		.layui-bottom{border-bottom:1px solid rgb(226, 226, 226);}
		.layui-input{height:30px !important; }
		.layui-form-search-item .layui-inline{margin-bottom: 5px;} 
		.layui-form-search-item label{margin-left: 15px;}
		.layui-table-page {padding: 7px 0px 0px;}
		.layui-field-padding{border-width: 1px;padding:0 0 5px 10px;}
	</style>		
</head>
<body>
<!-- layui-tab开始 -->
<div class="layui-tab " lay-filter="demo-tab">

	<fieldset class="layui-elem-field layui-field-title layui-field-padding">
		<legend class="layui-legend-size">权限设置</legend>
		<!-- 内容开始-->
    	<div id="set_auth" class="store-rbac1-tree"></div>
    	<!-- 内容结束-->
	</fieldset>
	

</div>
<include file='public/scripts' />
<script type="text/javascript">
var callback ;
;(function(){
    var tree = layui.tree;
    
    let baseInfo = {$baseInfo|default='[]'};

    tree.render({
        elem: '#set_auth'
        ,data: baseInfo
        ,showCheckbox:true
        ,onlyIconControl:true
        ,id:'rbac_menu'
    });
    tree.reload('rbac_menu',{data:baseInfo});
    callback = function ( index ){
        var checkData = tree.getChecked('rbac_menu');
        let roleId = {$role_id};
        let url = '{:cmf_plugin_url("Store://store_rbac/checkedRbacPost")}?role_id={$role_id}';
        comPost( url , {checkData:checkData} , function( res ){
            parent.layer.close( index );
        } );
        return true;
    }
    
    //提交
    function comPost( url , data , success , error ){
        $.post( url , data, function( res ){
            layer.msg( res.message , { icon:(res.code==200?1:5) , time:500 } , function(){
                if( res.code == 200 ){
                    
                    success && success( res );
                }else{
                    error && error( res );
                }
            } );
        } );
    }
})()
</script>
</body>
</html>